/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function dialogSetRights() {
        var userId = document.getElementsByClassName('row_selected')[0].id;
        $.ajax({
            "url": 'a_load_rights_dialog',
            "type": 'GET',
            "data": {"id":userId},
            "success": function(data){
                $.Dialog({
                    "title": "Права доступа",
                    "draggable": true,
                    "content": data,
                    "width" : 300
                });
            }
        });
}

var changes = [false,false];
    
    function processApplyRights() {
    var userId = document.getElementById("dialog_rights_userId").value;
    var isHr = document.getElementById("dialog_rights_hr").checked;
    var isManager = document.getElementById("dialog_rights_manager").checked;

    if (changes[0] || changes[1]) {
        $.ajax({
            "url":'a_change_roles',
            "type":'POST',
            "data":{"id":userId,"hr":isHr,"manager":isManager},
            "success": function() {
                    changes = [false,false];
                    setIcons(userId,isHr,isManager);
                    dialogSuccessfulClose('Изменения приняты.');
                }
            });
        }
    }

    function rightsChange(ind) {
         changes[ind] = !changes[ind];
    }

